package com.dfec.water.dao;

import com.dfec.framework.mybatis.core.mapper.BaseMapperX;
import com.dfec.framework.mybatis.core.page.PageParam;
import com.dfec.framework.mybatis.core.page.PageUtils;
import com.dfec.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.dfec.water.entity.YdbAreaImgEntity;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;

/**
 * 选择区域关联图片Dao接口
 *
 * @author df
 * @date Mon Jan 20 16:55:01 CST 2025
 */
@Mapper
public interface YdbAreaImgDao extends BaseMapperX<YdbAreaImgEntity> {

    /**
     * description:分页查询
     *
     * @param pageParam 分页参数
     * @return
     * @author trg
     * @date 2023/6/27 15:56
     */
    default PageUtils selectPage(PageParam<YdbAreaImgEntity> pageParam) {
        YdbAreaImgEntity entity = pageParam.getEntity() == null ? new YdbAreaImgEntity() :pageParam.getEntity();
        return this.selectPage(pageParam, dealParams(entity));
    }


    /**
     * 不带分页查询
     * @param ydbAreaImgEntity
     * @return
     */
    default  List<YdbAreaImgEntity> selectAll(YdbAreaImgEntity ydbAreaImgEntity){
        return this.selectList(dealParams(ydbAreaImgEntity));
    }

    /**
     * description:查询条件拼接
     *
     * @param entity 参数
     * @return
     * @author trg
     * @date 2023/6/27 15:56
     */
     default LambdaQueryWrapperX<YdbAreaImgEntity> dealParams(YdbAreaImgEntity entity){
        return new LambdaQueryWrapperX<YdbAreaImgEntity>()
                .eqIfPresent(YdbAreaImgEntity::getAreaId, entity.getAreaId())
                .likeIfPresent(YdbAreaImgEntity::getName, entity.getName())
                .eqIfPresent(YdbAreaImgEntity::getUrl, entity.getUrl())
                .eqIfPresent(YdbAreaImgEntity::getUploadTime, entity.getUploadTime())
                ;
    }


    /**
     * 根据区域id查询图片
     * @param areaId    区域id
     * @return
     */
    default List<YdbAreaImgEntity> listAllByAreaIds(List<Long> areaId){
         return this.selectList(new LambdaQueryWrapperX<YdbAreaImgEntity>().in(YdbAreaImgEntity::getAreaId,areaId));
    }


}
